<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Prepare an event</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.event-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">event_set</h1>
  <p class="verinfo">(PECL libevent &gt;= 0.0.1)</p><p class="refpurpose"><span class="refname">event_set</span> &mdash; <span class="dc-title">Prepare an event</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.event-set-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><a href="event.set.html" class="methodname">event_set</a></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$event</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$fd</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$events</code></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$callback</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$arg</code></span>
  ] ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Prepares the event to be used in <span class="function"><a href="event.add.html" class="function">event_add()</a></span>. The event
   is prepared to call the function specified by the <code class="parameter">callback</code> 
   on the events specified in parameter <code class="parameter">events</code>, which
   is a set of the following flags: <strong><code>EV_TIMEOUT</code></strong>, 
   <strong><code>EV_SIGNAL</code></strong>, <strong><code>EV_READ</code></strong>, 
   <strong><code>EV_WRITE</code></strong> and <strong><code>EV_PERSIST</code></strong>.
  </p> 
  <p class="para">
   If <strong><code>EV_SIGNAL</code></strong> bit is set in parameter <code class="parameter">events</code>,
   the <code class="parameter">fd</code> is interpreted as signal number.
  </p>
  <p class="para">
   After initializing the event, use <span class="function"><a href="event_base_set.html" class="function">event_base_set()</a></span> to
   associate the event with its event base.
  </p>
  <p class="para">
   In case of matching event, these three arguments are passed to the
   <code class="parameter">callback</code> function: 
   <dl>

    
     <dt>
<code class="parameter">fd</code></dt>

     <dd>

      <p class="para">
       Signal number or resource indicating the stream.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">events</code></dt>

     <dd>

      <p class="para">
       A flag indicating the event. Consists of the following flags:
       <strong><code>EV_TIMEOUT</code></strong>, <strong><code>EV_SIGNAL</code></strong>, 
       <strong><code>EV_READ</code></strong>, <strong><code>EV_WRITE</code></strong>
       and <strong><code>EV_PERSIST</code></strong>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">arg</code></dt>

     <dd>

      <p class="para">
       Optional parameter, previously passed to <span class="function"><a href="event.set.html" class="function">event_set()</a></span>
       as <code class="parameter">arg</code>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.event-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">event</code></dt>

     <dd>

      <p class="para">
       Valid event resource.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">fd</code></dt>

     <dd>

      <p class="para">
       Valid PHP stream resource. The stream must be castable to file
       descriptor, so you most likely won&#039;t be able to use any of filtered
       streams.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">events</code></dt>

     <dd>

      <p class="para">
       A set of flags indicating the desired event, can be
       <strong><code>EV_READ</code></strong> and/or <strong><code>EV_WRITE</code></strong>.
       The additional flag <strong><code>EV_PERSIST</code></strong> makes the event
       to persist until <span class="function"><a href="event.del.html" class="function">event_del()</a></span> is called, otherwise
       the callback is invoked only once. 
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">callback</code></dt>

     <dd>

      <p class="para">
       Callback function to be called when the matching event occurs.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">arg</code></dt>

     <dd>

      <p class="para">
       Optional callback parameter.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.event-set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="function"><a href="event.set.html" class="function">event_set()</a></span> returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.event-set-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>0.0.4</td>
      <td>
       <strong><code>EV_SIGNAL</code></strong> support was added.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


</div></div></div></body></html>